package com.wanglibao.woodtrade.woodtrade.ui.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.wanglibao.woodtrade.woodtrade.R;
import com.wanglibao.woodtrade.woodtrade.ui.activity.adapter.ItemLvContactBuyActivityAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/*
   供需信息界面中 我要买货的界面
 */
public class BuyActivity extends BaseActivity {

    @Bind(R.id.tv_contact_title_buy_avtivity)
    TextView mTvContactTitleBuyAvtivity;
    @Bind(R.id.tv_contact_price1_buy_avtivity)
    TextView mTvContactPrice1BuyAvtivity;
    @Bind(R.id.bt_contact_buy_avtivity)
    Button mBtContactBuyAvtivity;
    @Bind(R.id.lv_information_buy_activity)
    ListView mLvInformationBuyActivity;
//=============================
    ItemLvContactBuyActivityAdapter mAdapter;
    private List<String> mList=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_buy);
        ButterKnife.bind(this);
        for(int i=0;i<6;i++){
            mList.add("品名"+i);
        }
        initData();
    }

    private void initData() {
        tvTitle.setText("商品详情");
        addViewClicklistener(tvBack,mBtContactBuyAvtivity);
        mAdapter=new ItemLvContactBuyActivityAdapter(this,mList);
        mLvInformationBuyActivity.setAdapter(mAdapter);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch(v.getId()){
            case R.id.tv_commonTitle_back:
                finish();
                overridePendingTransition(R.anim.extre_in,R.anim.extre_out);
                break;
            case R.id.bt_contact_buy_avtivity:
                // 打电话
               
                final String forPhoneNum = "10086";
                
                final AlertDialog.Builder builder=new AlertDialog.Builder(BuyActivity.this);
                builder.setMessage("呼叫："+forPhoneNum).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        
                    }
                }).setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent=new Intent();
                        intent.setAction("android.intent.action.CALL");
                        intent.setData(Uri.parse("tel:"+forPhoneNum));
                        startActivity(intent); 
                    }
                }).create();
                builder.show();
                break;
            default:
                break;
        }
            
    }
}
